package com.task.domain;

import org.apache.commons.codec.digest.DigestUtils;

import java.io.Serializable;


/**
 * @className: 用户
 * @description: 操作员信息
 * @author: chenxiang
 * @date: 2014-11-27 下午1:57:09
 */
public class SysOperator implements Serializable {
    private static final long serialVersionUID = -7059331243549997464L;

    /**
     * 主键
     */
    private Long operatorId;

    /**
     * 电子邮箱
     */
    private String operatorEmail;

    /**
     * 登陆名称
     */
    private String operatorLoginName;

    /**
     * 用户名称
     */
    private String operatorDisplayName;

    /**
     * 登陆密码
     */
    private String operatorPassword;

    private OperatorState operatorState;

    private String operatorStateName;

    private Long organizationId;

    private String organizationName;

    private String operatorIp;

    private String salt;

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public Long getOperatorId() {
        return operatorId;
    }

    public void setOperatorId(Long operatorId) {
        this.operatorId = operatorId;
    }

    public OperatorState getOperatorState() {
        return operatorState;
    }

    public void setOperatorState(OperatorState operatorState) {
        this.operatorState = operatorState;
        this.operatorStateName = operatorState.getDisplayName();
    }


    public String getOperatorEmail() {
        return operatorEmail;
    }

    public void setOperatorEmail(String operatorEmail) {
        this.operatorEmail = operatorEmail;
    }

    public String getOperatorLoginName() {
        return operatorLoginName;
    }

    public void setOperatorLoginName(String operatorLoginName) {
        this.operatorLoginName = operatorLoginName == null ? "" : operatorLoginName.trim();
    }

    public String getOperatorDisplayName() {
        return operatorDisplayName;
    }

    public void setOperatorDisplayName(String operatorDisplayName) {
        this.operatorDisplayName = operatorDisplayName == null ? "" : operatorDisplayName.trim();
    }

    public String getOperatorPassword() {
        return operatorPassword;
    }

    public void setOperatorPassword(String operatorPassword) {
        this.operatorPassword = operatorPassword == null ? "" : operatorPassword.trim();
    }

    public String getOperatorStateName() {
        return operatorStateName;
    }

    public void setOperatorStateName(String operatorStateName) {
        this.operatorStateName = operatorStateName;
    }

    /**
     * 增加一个密码检查接口
     *
     * @return
     */
    public boolean checkPassword(String operatorPassword) {
        return DigestUtils.md5Hex(operatorPassword.trim()).equals(this.operatorPassword);
    }

    public enum OperatorState {
        NORMAL("正常"), LOCK("锁定"), CANCEL("注销");
        private String msg;

        private OperatorState(String msg) {
            this.msg = msg;
        }

        public String getDisplayName() {
            return this.msg;
        }
    }


    public Long getOrganizationId() {
        return organizationId;
    }

    public void setOrganizationId(Long organizationId) {
        this.organizationId = organizationId;
    }

    public String getOrganizationName() {
        return organizationName;
    }

    public void setOrganizationName(String organizationName) {
        this.organizationName = organizationName;
    }

    public String getOperatorIp() {
        return operatorIp;
    }

    public void setOperatorIp(String operatorIp) {
        this.operatorIp = operatorIp;
    }

}